//
// Copyright (c) 2024 BPer
//
#ifndef BPERCAPTURE_BPerAudioCaptureMac_H_
#define BPERCAPTURE_BPerAudioCaptureMac_H_
#include <bperaudiodev/BPerAudioCaptureHandle.h>

#include <bperaudiodev/BPerAudioCapture.h>
#include <bperavutil/audio/BPerPreProcess.h>
#include <bperutil/buffer/BPerAudioPlayBuffer.h>
#include <vector>

#if BPer_OS_APPLE
#include <bperaudiodev/mac/BPerAudioMac.h>
using namespace std;

class BPerAudioCaptureMac: public BPerAudioCapture {
public:
	BPerAudioCaptureMac(BPerAVInfo *avinfo);
	~BPerAudioCaptureMac();
public:
	BPerAudioCaptureHandle *m_ahandle;
	int32_t init();
	void setPreProcess(BPerPreProcess *pp);
	void setCatureStart();
	void setCatureStop();
	void setOutAudioBuffer(BPerAudioBuffer *pbuffer);
	void setPlayAudoBuffer(BPerAudioBuffer *pbuffer);
	void setInAudioBuffer(vector<BPerAudioPlayBuffer*> *pal);
	void setAec(BPerRtcAec *paec);
    void on_audio(uint8_t* data,uint32_t nb);

protected:
	void startLoop();
	void stopLoop();

private:
	BPerAVInfo *m_avinfo;

	int32_t m_loops;
	int32_t m_channel;
	uint32_t  m_sample;
    uint32_t m_macSample;
    uint32_t m_macChannel;
    uint32_t m_size;
	uint8_t *m_buffer;
    uint32_t m_bufferLen;
    BPerBool m_isInited;

    BPerAudioMac* m_macAudio;
    BPerAudioPlayBuffer* m_bufferList;

	BPerBool onlySupportSingle;
    BPerMacAudioCallback m_callback;
    BPerAudioResample m_resample;
    BPerFrame m_audioFrame;

};
#endif
#endif /* BPERCAPTURE_SRC_BPERAUDIOCAPTUREIMPL_H_ */
